package com.sofa.shark.file.entity;

import com.sofa.shark.common.core.enums.ExceptionEnums;
import lombok.Data;

import java.io.Serializable;

/**
 * @author tonyp
 * @date 2019/11/1
 * @description
 * 文件服务返回的对象
 * */
@Data
public class FileServerResponse<T> implements Serializable {

    public static final String SUCCESS_CODE = "ok";
    public static final String  ERROR_CODE = "fail";

    private String  status;

    private String message;

    private T data;

    public FileServerResponse(String status, String msg, T data) {
        this.status = status;
        this.message = msg;
        this.data = data;
    }

    public static <T> FileServerResponse<T> error(String message) {
        return new FileServerResponse<>(ERROR_CODE, message, null);
    }

    public static <T> FileServerResponse<T> error(ExceptionEnums exceptionEnums) {
        return new FileServerResponse<>(ERROR_CODE, exceptionEnums.getName(), null);
    }
}
